package com.dt76.smallloanbackendservice.service.lhuaw.impl;

import com.dt76.smallloanbackendservice.mapper.lhuaw.UserFeedbackMapper;
import com.dt76.smallloanbackendservice.pojo.lhuaw.UserFeedback;
import com.dt76.smallloanbackendservice.service.lhuaw.UserFeedbackService;
import com.dt76.smallloanbackendservice.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserFeedbackServiceImpl implements UserFeedbackService {

    @Autowired
    private UserFeedbackMapper userFeedbackMapper;

    @Override
    public List<UserFeedback> qryAllFeedback() {
        return userFeedbackMapper.qryAllFeedback();
    }

    @Override
    public Page qryConditionPageAllFeedback(int pageIndex, String userName, String feedbackQuestion) {
        Page page = new Page();
        page.setPageIndex(pageIndex);
        page.setTotalCount(userFeedbackMapper.qryConditionCountFeedback(userName, feedbackQuestion));
        List<UserFeedback> userFeedbackList = userFeedbackMapper.qryConditionPageAllFeedback((page.getPageIndex() - 1) * page.getPageSize(),
                page.getPageSize(), userName, feedbackQuestion);
        System.out.println(userFeedbackList);
        page.setRows(userFeedbackList);
        return page;
    }

    @Override
    public void deleteFeedback(int uId) {
        userFeedbackMapper.deleteFeedback(uId);
    }
}
